﻿using System;
using System.Data.OleDb;

namespace Ooaavee.Data
{
    /// <summary>
    /// Provides database connections.
    /// </summary>
    internal sealed class Connections
    {
        private readonly RelationalModelSource _source;

        /// <summary>
        /// Creates a new instance of the Connections class.
        /// </summary>
        /// <param name="source">The source of the relational model.</param>
        internal Connections(RelationalModelSource source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            _source = source;
        }

        /// <summary>
        /// Opens a new OleDb database connection.
        /// </summary>
        /// <returns>A new OleDb database connection.</returns>
        internal OleDbConnection GetOleDbConnection()
        {
            OleDbConnection con = new OleDbConnection();
            con.ConnectionString = _source.OleDbConnectionString;
            con.Open();
            return con;
        }
    }
}
